<style scoped>
  .weui-form-preview {
    background-color: #fff;
    margin: 5px;
    border-radius: 5px;
  }

  .weui-form-preview__hd label, .weui-form-preview__hd em {
    font-size: .9em !important;
  }

  .weui-panel__bd {
    width: auto !important;
    padding: 10px 15px;
    text-align: left;
  }
  .rj-cell {
    font-size: 0.9em;
    display: inline-block;
    margin-right: 15px;
  }
  .section {
    margin: 5px;
    border-radius: 5px;
  }
  .weui-panel {
    background: #eee;
  }

  .rj-cont-tit {
    margin: 0;
    border-radius: 0;
  }

  .weui-panel {
    margin-top: 0;
    text-align: left;
  }

  .attachimg {
    /*width: 100%;*/
  }

  .tit label, .tit span {
    font-size: 16px;
  }

  .tit label {
    padding-right: 20px;
  }

  .weui-panel.weui-panel_access {
    padding-bottom: 10px;
  }

  .weui-panel__bd:not(.base) {
    width: 98%;
    padding: 0 1% 2px 1%;
  }

  .rj-cont-tit:not(.base) {
    border-radius: 5px;
  }

  .weui-cell {
    background: #fff;
  }

  .weui-cells__title {
    text-align: left;
    background: #eee;
  }

  .oitem {
    padding: 3px;
  }

  #acts span {
    font-size: 14px;
  }

  .weui-label {
    text-align: left;
  }

  .weui-media-box {
    text-align: left;
  }

  .weui-panel {
    background: #eee;
  }

  .rj-cont-tit {
    margin: 0;
    border-radius: 0;
  }

  .weui-panel {
    margin-top: 0;
    text-align: left;
  }

  .hd .weui-grid.js_grid {
    font-weight: 600;
  }

  .weui-grid.js_grid {
    width: 25%;
    padding: 10px 1px;
  }

  /*.weui-grid.fir {*/
  /*  width: 20%;*/
  /*}*/
  /*.weui-grid.sec {*/
  /*  width: 15%;*/
  /*}*/
  /*.weui-grid.thr {*/
  /*  width: 20%;*/
  /*}*/
  /*.weui-grid.fou {*/
  /*  width: 15%;*/
  /*}*/
  /*.weui-grid.fiv {*/
  /*  width: 15%;*/
  /*}*/
  .weui-grid__label {
    text-overflow: initial;
  }

  /*.view-wrap {*/
  /*  background: #eee;*/
  /*}*/
  .section {
    width: auto;
    margin: 5px;
    border-radius: 5px;
    text-align: left;
    overflow: hidden;
  }
  .itemSection {
    background: #fafafa;
    margin: 3px;
  }
  .itemTit {
    color: #999;
    font-size: 12px;
    margin-left: 15px;
  }
</style>
<template>
  <div class="comon" style="background: #eee;padding-bottom: 50px;">
    <div
      style="height: 50px; line-height: 50px; background: #fff; text-align: center; font-size: 16px; border-bottom: 1px solid #bdbbbc; position: relative">
      领料入库详情
      <a href="javascript:;" @click="$router.back(-1)" style="position: absolute; left: 10px; top: 8px">
        <img src="@/assets/back.png" style="width: 20px"/>
      </a>
    </div>
    <!--    主表信息-->
    <div class="weui-form-preview" style="background: #fff;">
      <div class="weui-form-preview__hd">
        <label class="weui-form-preview__label">编号</label>
        <em class="weui-form-preview__value">{{baseInfo.code}}</em>
      </div>
      <div class="weui-form-preview__bd">
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">领料单编号</label>
          <span class="weui-form-preview__value">{{baseInfo.pickcode}}</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">生产计划编号</label>
          <span class="weui-form-preview__value">{{baseInfo.planCode}}</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">所在班组</label>
          <span class="weui-form-preview__value">{{baseInfo.deptName}}</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">领料类别</label>
          <span class="weui-form-preview__value">{{baseInfo.pickTypeName}}</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">出库库房</label>
          <span class="weui-form-preview__value">{{baseInfo.strname}}</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">库存组织</label>
          <span class="weui-form-preview__value">{{baseInfo.orgname}}</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">备注</label>
          <span class="weui-form-preview__value">{{baseInfo.remark}}</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">状态</label>
          <span class="weui-form-preview__value">{{baseInfo.statusName}}</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">提交人</label>
          <span class="weui-form-preview__value">{{baseInfo.createName}}</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">创建时间</label>
          <span class="weui-form-preview__value">{{baseInfo.createtime}}</span>
        </div>
        <div class="weui-form-preview__item" v-if="orderfiles && orderfiles.length > 0">
          <label class="weui-form-preview__label">附件</label>
          <div class="exp uploaderFiles" style="display: inline-block;">
            <img class="attachimg" style="padding-right: 5px;"  v-for="(image, index) in orderfiles" :key="image.guid"  alt="" onerror="javascript:this.src='../../../../static/image/default.png';this.onerror = null" :src="image.url + '-suolue.png'" :data-img="image.url + '.png'" />
          </div>
        </div>
      </div>
    </div>
    <!--    明细信息-->
    <div class="weui-panel__hd" style="text-align: left;">货品明细</div>
    <div class="weui-panel__bd section" v-for="product in baseInfo.items" style="background: #fff;">
      <div class="rj-cell max">
        <label>类型：</label>
        {{product.typeName}}
      </div>
      <div class="rj-cell max">
        <label>产品：</label>
        {{product.product}} {{product.spename}}
      </div>
      <div class="rj-cell max">
        <label>数量：</label><span>{{attachUnit(product.weight, product.stockunit)}}</span>
      </div>
      <div class="rj-cell max">
        <label>库间：</label><span>{{product.housename}}</span>
      </div>
    </div>
    <SalesOperationLogs7 :nodeid="nodeid" :orderid="id" :srguid="baseInfo.srguid" :departid="baseInfo.departid" :flowid="flowid"></SalesOperationLogs7>
    <CommentBom v-if="isReady" :flowid="flowid" :nodeid="nodeid" :id="id" :srguid="baseInfo.srguid" :departid="baseInfo.departid" :model="baseInfo"  navgateUrl="/applystorerm2/ApplyStoreRmList" ></CommentBom>
  </div>
</template>

<script>
  import SalesOperationLogs7 from '../common/SalesOperationLogs7'
  import CommentBom from '@/components/common/CommentBom'

  export default {
    name: 'ViewApplyStoreRm2',
    data() {
      return {
        flowid: 33,
        openid: localStorage.openid,//'oIuV2v77MaLCAQILhjI6h6oTWpHI',
        userid: localStorage.userId,//'oIuV2v77MaLCAQILhjI6h6oTWpHI',
        id: '',
        baseInfo: {},
        orderfiles: []
      }
    },
    components: {
      SalesOperationLogs7,
      CommentBom
    },
    created() {
      window.addEventListener('setItem', () => {
        this.openid = localStorage.getItem('openid');
        this.userid = localStorage.getItem('userId');
      })
    },
    mounted() {
      this.id = this.$route.query.id;
      this.getbaseInfo(this.id);
      this.getFiles();
      //图片浏览器
      $('.weui-panel').on('click', '.uploaderFiles .attachimg', function () {
        var num = $(this).parent().children().not(".exp").length;
        var imgArr = [];
        for (var i = 0; i < num; i++) {
          imgArr.push($(this).parent().find('.attachimg').eq(i).data('img'));
        }
        var pnum = $(this).parent().find('.exp').length;
        var index = pnum > 0 ? $(this).index() - pnum : $(this).index();
        var pb = $.photoBrowser({
          items: imgArr,
          initIndex: index
        });
        pb.open();
      });

    },
    methods: {
      packUnit: function(unit, currency) {
        return unit != undefined && unit != '' ? currency == 2 ? '美元/' + unit : '元/' + unit : '';
      },
      getFiles: function () {
        let that = this;
        this.axios({
          method: 'get',
          url: '/sales/Fileinfo!getFileinfo.action',
          params: {orderid: this.id}
        }).then(response => {
          if (response.data.msg == 'success') {
            this.orderfiles = response.data.files;
          } else {
            //失败时不提示
          }
        });
      },
      getbaseInfo: function (id) {
        this.axios({
          method: 'get',
          url: `/prod-api/produce/whinapply/${id}`,
        }).then(response => {
          if (response.data.code == 200) {
            let data = response.data;
            this.baseInfo = data.data || {};
            // this.baseItems = response.data.items;
          } else if (response != undefined && response.data != undefined && response.data.msg == 'sessionTimeOut') {
            //不不设置提示
          } else {
            this.toastError('系统错误');
          }
          this.isReady = true;
        });
      },
    }
  }
</script>
